﻿@using vITs.Site.Models
@model IEnumerable<vITs.Site.Models.DataModels.PerDiemSpecification>
@{
    this.ViewBag.Title = "Traktamentesspecifikationer för år " + this.ViewBag.Year;
}
<h2>@this.ViewBag.Title</h2>
<p>
    @Html.ActionLink("Lägg till Ny", "Create") |
    Visa för år: 
    <select id="Year">
    @foreach (int i in Utilities.GetValidYears())
    {
        var selected = (i.ToString() == this.ViewBag.Year ? "selected=\"selected\"" : "");
        <option @selected value="@i">@i</option>
    }
    </select>
    <input type="button" value="Visa" onclick="javascript:gotoYear();" />
</p>
<table>
    <thead>
        <tr>
            <th>Land</th>
            <th>Summa</th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model) {
        <tr>
            <td>
                @item.Country.ToSentenceCasing()
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Sum)
            </td>
            <td>
                @Html.ActionLink("Redigera", "Edit", new { Year = item.Year, Country = item.Country }) |
                @Html.ActionLink("Radera", "Delete", new { Year = item.Year, Country = item.Country }, new { onclick = "javascript:return confirm('Är du säker?');" })
            </td>
        </tr>
}
    </tbody>
</table>
<script type="text/javascript">
    function gotoYear() {
        var ddlYear = document.getElementById("Year");
        var url = '@this.Url.Action("Index")?Year=' + ddlYear.value;
        window.location = url;
    }
</script>
